package com.bw.session.controller;

import com.bw.common.result.Result;
import com.bw.session.domain.Scheduled;
import com.bw.session.domain.Session;
import com.bw.session.domain.vo.SessionVO;
import com.bw.session.service.ScheduledService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("scheduled")
@CrossOrigin
public class ScheduledController {

    @Autowired
    private ScheduledService scheduledService;

    @GetMapping("/selectSession")
    public Result selectSession(){
        List<Scheduled> sessions = scheduledService.selectSession();
        return Result.success(sessions);
    }

    @PutMapping("/updateScheduled")
    public Result updateScheduled(@RequestBody Scheduled scheduled){
        scheduledService.updateScheduled(scheduled);
        return Result.success();
    }

    @DeleteMapping("/deleteScheduled/{id}")
    public Result deleteScheduled(@PathVariable Integer id){
        scheduledService.deleteScheduled(id);
        return Result.success();
    }

    @PostMapping("/insertScheduled")
    public Result insertScheduled(@RequestBody Scheduled scheduled){
        scheduledService.insertScheduled(scheduled);
        return Result.success();
    }

}
